package com.hongji.lms5xxcommunicator.scannerSettingWindow;

import java.util.Objects;

/**
 * 解析自 LMDscandata 报文头（DIST1 区块）的元信息：
 * scale、offset、startAngleDeg、stepAngleDeg、count、distanceStartIdx。
 */
public final class LmdMeta {
    public final double scale;           // 距离缩放（例如 1.0 表示 mm）
    public final double offset;          // 距离偏移
    public final double startAngleDeg;   // 起始角（度）
    public final double stepAngleDeg;    // 角步进（度）
    public final int count;              // 距离点数
    public final int distanceStartIdx;   // 在 tokens[] 中距离序列的起始下标

    public LmdMeta(double scale, double offset, double startAngleDeg, double stepAngleDeg, int count, int distanceStartIdx) {
        this.scale = scale;
        this.offset = offset;
        this.startAngleDeg = startAngleDeg;
        this.stepAngleDeg = stepAngleDeg;
        this.count = count;
        this.distanceStartIdx = distanceStartIdx;
    }

    @Override
    public String toString() {
        return "LmdMeta{" +
                "scale=" + scale +
                ", offset=" + offset +
                ", startAngleDeg=" + startAngleDeg +
                ", stepAngleDeg=" + stepAngleDeg +
                ", count=" + count +
                ", distanceStartIdx=" + distanceStartIdx +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof LmdMeta)) return false;
        LmdMeta m = (LmdMeta) o;
        return Double.compare(m.scale, scale) == 0
                && Double.compare(m.offset, offset) == 0
                && Double.compare(m.startAngleDeg, startAngleDeg) == 0
                && Double.compare(m.stepAngleDeg, stepAngleDeg) == 0
                && m.count == count
                && m.distanceStartIdx == distanceStartIdx;
    }

    @Override
    public int hashCode() {
        return Objects.hash(scale, offset, startAngleDeg, stepAngleDeg, count, distanceStartIdx);
    }
}
